import { Injectable } from '@angular/core';
import { RequestClass } from './request.service';
@Injectable()
export class WellService {
    constructor(private requestclass: RequestClass) {}
    // http://115.157.195.222:3000/project/16/interface/api/60
    fetchWellInfoByConfig = async ({
        wellCode,
        wellName,
        address,
        applicantName,
        wellId,
    }) => {
        return await this.requestclass.request.get(
            '/wellinfo/findwellinfosbyconditions',
            {
                params: {
                    wellCode,
                    wellName,
                    address,
                    applicantName,
                    wellId,
                },
            }
        );
    };
    fetchWellYearPredictById = async ({ wellId }) => {
        return await this.requestclass.request.get(
            '/wellinfo/predictvolumebyyear',
            {
                params: {
                    well_id: wellId,
                },
            }
        );
    };
    fetchWellMonthPredictById = async ({ wellId, year }) => {
        return await this.requestclass.request.get(
            '/wellinfo/getmonthpredict',
            {
                params: {
                    wellId: wellId,
                    year: year,
                },
            }
        );
    };

    fetchWellYearTotalById = async ({ wellId }) => {
        return await this.requestclass.request.Pget(
            '/wellinfo/findvolumebyyear',
            {
                params: {
                    well_id: wellId,
                },
            }
        );
    };

    fetchVolumeListByConfig = async ({ applicantName }) => {
        return await this.requestclass.request.get('/plan/getplanvolumelist', {
            params: {
                applicantName,
            },
        });
    };

    fetchPrevVolumeByConfig = async ({ applicantId, planYear }) => {
        return await this.requestclass.request.get('/plan/getpastplanvolume', {
            params: {
                applicantId,
                planYear,
            },
        });
    };

    fetchWellInfoById = async ({ wellId }) => {
        return await this.requestclass.request.get(
            '/wellinfo/getwellinfobywellid',
            {
                params: {
                    wellId,
                },
            }
        );
    };

    // 更新机井信息
    // http://115.157.195.222:3000/project/16/interface/api/70
    updateWellInfoByConfig = async ({
        wellId,
        // 名称编号
        wellName,
        wellCode,
        // 口径井深
        wellCaliber,
        wellDepth,
        // 时间
        createTime,
        // 地点
        zoneId,
        zoneType,
        // 用途类型
        wellUsage,
        wellType,
        // 经纬度
        longitude,
        latitude,
        // 状态
        status,
        // 通讯编号
        comNumber,
        // 灌溉面积
        irrigationArea,
        // 备注
        remark,
    }) => {
        return await this.requestclass.request.put('/wellinfo/updatewellinfo', {
            data: {
                wellId,
                // 名称编号
                wellName,
                wellCode,
                // 口径井深
                wellCaliber,
                wellDepth,
                // 时间
                createTime,
                // 地点
                zoneId,
                zoneType,
                // 用途类型
                wellUsage,
                wellType,
                // 经纬度
                longitude,
                latitude,
                // 状态
                status,
                // 通讯编号
                comNumber,
                // 灌溉面积
                irrigationArea,
                // 备注
                remark,
            },
        });
    };

    updateRemarkById = async ({ id, remark }) => {
        return await this.requestclass.request.put('/wellinfo/updateremark', {
            params: {
                well_id: id,
                remark,
            },
        });
    };

    // 删除机井
    // http://115.157.195.222:3000/project/16/interface/api/71
    deleteWellInfoById = async ({ well_ids }) => {
        return await this.requestclass.request.delete(
            '/wellinfo/deletewellinfo',
            {
                params: {
                    well_id: well_ids,
                },
            }
        );
    };

    // 新增机井信息
    // http://115.157.195.222:3000/project/16/interface/api/72
    addWellInfoByConfig = async ({
        // 名称编号
        wellName,
        wellCode,
        // 口径井深
        wellCaliber,
        wellDepth,
        // 时间
        createTime,
        // 地点
        zoneId,
        zoneType,
        // 用途类型
        wellUsage,
        wellType,
        // 经纬度
        longitude,
        latitude,
        // 状态
        status,
        // 通讯编号
        comNumber,
        // 灌溉面积
        irrigationArea,
        // 备注
        remark,
        applicantId,
    }) => {
        return await this.requestclass.request.post(
            '/wellinfo/insertwellinfo',
            {
                params: {
                    applicantId,
                },
                data: {
                    // 名称编号
                    wellName,
                    wellCode,
                    // 口径井深
                    wellCaliber,
                    wellDepth,
                    // 时间
                    createTime,
                    // 地点
                    zoneId,
                    zoneType,
                    // 用途类型
                    wellUsage,
                    wellType,
                    // 经纬度
                    longitude,
                    latitude,
                    // 状态
                    status,
                    // 通讯编号
                    comNumber,
                    // 灌溉面积
                    irrigationArea,
                    // 备注
                    remark,
                },
            }
        );
    };

    // 4.6 新接口
    // 更新机井状态
    // http://115.157.195.222:3000/project/16/interface/api/102
    updateWellStatusByStatus = async ({ wellId, status }) => {
        return await this.requestclass.request.put('/wellinfo/updatestatus', {
            data: {
                well_id: wellId,
                status,
            },
        });
    };
    getPredictList = async ({}) => {
        return await this.requestclass.request.get('/wellinfo/predictline', {});
    };

    predictWell = async ({ hour, minute, temperature, pressure }) => {
        return await this.requestclass.request.put('/wellinfo/predictbreakbytime', {
            params: {
                hour,
                minute,
                temperature,
                pressure,
            },
        });
    };
}
